// 页面加载状态管理
export const usePageLoading = () => {
  const isPageLoading = useState<boolean>('pageLoading', () => false)
  const pageLoadingType = useState<'home' | 'detail' | 'list' | 'shorts'>('pageLoadingType', () => 'home')

  const startPageLoading = (type: 'home' | 'detail' | 'list' | 'shorts' = 'home') => {
    isPageLoading.value = true
    pageLoadingType.value = type
  }

  const stopPageLoading = () => {
    // 添加一点延迟，让过渡更平滑
    setTimeout(() => {
      isPageLoading.value = false
    }, 300)
  }

  return {
    isPageLoading: readonly(isPageLoading),
    pageLoadingType: readonly(pageLoadingType),
    startPageLoading,
    stopPageLoading
  }
}